package echo.netty.TestProtocol;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @author： zhangnan
 * @date： 2025/5/12 11:46
 * @description： 测试协议消息的公共父类
 * @modifiedBy：
 * @version: 1.0
 */
@Data
public abstract class Message implements Serializable {

    public static Class<?> getMessageClass(int messageType) {
        return messageClasses.get(messageType);
    }

    private int sequenceId;
    private int messageType;

    public abstract int getMessageType();

    /**
     * 聊天类型
     */
    public static final int LoginRequestMessage = 0;
    public static final int LoginResponseMessage = 1;
    public static final int chatRequestMessage = 2;
    public static final int chatResponseMessage = 3;
    public static final int GroupCreateRequestMessage = 4;
    public static final int GroupCreateResponseMessage = 5;
    public static final int GroupJoinRequestMessage = 6;
    public static final int GroupJoinResponseMessage = 7;
    public static final int GroupQuitRequestMessage = 8;
    public static final int GroupQuitResponseMessage = 9;
    public static final int GroupChatRequestMessage = 10;
    public static final int GroupChatResponseMessage = 11;
    public static final int GroupMembersRequestMessage = 12;
    public static final int GroupMembersResponseMessage = 13;
    public static final int PingMessage = 14;
    private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();


    static {

        messageClasses.put(LoginRequestMessage,LoginRequestMessage.class);
//        messageClasses.put(LoginResponseMessage,LoginResponseMessage.class);
//        messageClasses.put(chatRequestMessage,chatRequestMessage.class);
//        messageClasses.put(chatResponseMessage,chatResponseMessage.class);
//        messageClasses.put(GroupCreateRequestMessage, GroupCreateRequestMessage.class);
//        messageClasses.put(GroupCreateResponseMessage,GroupCreateResponseMessage.class);
//        messageClasses.put(GroupJoinRequestMessage,GroupJoinRequestMessage.class);
//        messageClasses.put(GroupJoinResponseMessage,GroupJoinResponseMessage.class);
//        messageClasses.put(GroupQuitRequestMessage,GroupQuitRequestMessage.class);
//        messageClasses.put(GroupQuitResponseMessage，GroupQuitResponseMessage.class);
//        messageClasses.put(GroupChatRequestMessage,GroupChatRequestMessage.class);
//        messageClasses.put(GroupChatResponseMessage,GroupChatResponseMessage.class);
//        messageClasses.put(GroupMembersRequestMessage,GroupMembersRequestMessage.class);
//        messageClasses.put(GroupMembersResponseMessage,GroupMembersResponseMessage.class);


    }
}
